﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

// -----------------------------------------------------------------------
// <copyright file="$safeitemrootname$.cs" company="$registeredorganization$">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace ObjectLibrary
{
    public abstract class VisibleGameEntity3D : GameEntity
    {
        protected static ContentManager _content;
        protected static GraphicsDevice _graphicsDevice;
        protected MyModel _model;    
   
        private Vector3 _position = Vector3.Zero;
        private float _scale = 1f;
        private float _rotationY = 0;
//        private float _rotationZ = 0;

        public static void SetContent(ContentManager content)
        {
            _content = content;
        }
        public static void SetGraphicsDevice(GraphicsDevice graphicsDevice)
        {
            _graphicsDevice = graphicsDevice;
        }
 
 
        public float RotationY
        {
            get { return _rotationY; }
            set
            {
                _rotationY = value;
                if (_rotationY > MathHelper.TwoPi)
                {
                    _rotationY -= MathHelper.TwoPi;
                }
                else if (_rotationY < 0)
                {
                    _rotationY += MathHelper.TwoPi;
                }
                _model.RotationY =_rotationY;
            }
        }

        /*public Matrix Rotation
        {
            get { return _model.RotationY; }
        }*/

        public float Scale
        {
            get { return _scale; }
            set
            {
                _scale = value;
                _model.Scale = value;
            }
        }


        public Vector3 Position
        {
            get { return _position; }
            set
            {
                _position = value;
                _model.Position = value;
            }
        }

        virtual public void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Effect effect, MyCamera camera)
        {
            _model.Draw(gameTime, graphicsDevice, effect, camera);
        }

        virtual public void Update(GameTime gameTime)
        {
            _model.Update(gameTime);
        }
    }
}
